home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / GLUT-3.7 / PROGS / GLE / HELIXTEX.C < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-12  |  1.0 KB  |  47 lines

  1.  
  2. /* 
  3.  * helicoid (gernalized torus) demo 
  4.  *
  5.  * FUNCTION:
  6.  * This code provides a very simple example of the helicoid primitive.
  7.  *
  8.  * =======> MOUSE HOOKED UP TO SWEEP, HEIGHT < ========
  9.  *
  10.  * HISTORY:
  11.  * Written by Linas Vepstas, March 1995
  12.  */
  13.  
  14. /* required include files */
  15. #include <GL/glut.h>
  16. #include <GL/tube.h>
  17. #include "texture.h"
  18.  
  19. /*  most recent mouse postion */
  20. extern float lastx;
  21. extern float lasty;
  22.  
  23. void InitStuff (void) {}
  24.  
  25. /* draw the helix shape */
  26. void DrawStuff (void) {
  27.  
  28.    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  29.  
  30.    /* set up some matrices so that the object spins with the mouse */
  31.    glPushMatrix ();
  32.    glTranslatef (0.0, 0.0, -80.0);
  33.    glRotatef (220.0, 0.0, 1.0, 0.0);
  34.    glRotatef (65.0, 1.0, 0.0, 0.0);
  35.  
  36.    /* Phew. FINALLY, Draw the helix  -- */
  37.    gleSetJoinStyle (TUBE_NORM_EDGE | TUBE_JN_ANGLE | TUBE_JN_CAP);
  38.    gleHelicoid (1.0, 6.0, -1.0, 
  39.                0.0, (0.02*lasty-2.0), 0x0, 0x0, 0.0, 6.0*lastx);
  40.  
  41.    glPopMatrix ();
  42.  
  43.    glutSwapBuffers ();
  44. }
  45.  
  46. /* ---------------------- end of file ------------------ */
  47.